package com.wanxi.util;

import com.wanxi.model.Student;

/**
 * 分隔符:将字符串通过某个字符（或者正则表达式）或者某个规则，
 * 进行分割成无数个字符串的数组
 */
public class MySplit {
    public static void main(String[] args) {
        String str = "张三,23";
        String username = "";
        int age = 0;
        String[] split = str.split(",");
        username = split[0];
        age = Integer.parseInt(split[1]);

        System.out.println("姓名：" + username + " 年龄：" + age);
        Student student = getStudent(username, age);
        System.out.println(student);
    }


    /**
     * 一个方法里面只做一件事情
     * @param username
     * @param age
     * @return
     */
    private static Student getStudent(String username, int age) {
        return new Student(username, age);
    }

}
